package com.situ.mall.web.controller;

import com.situ.mall.common.entity.Product;
import com.situ.mall.common.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/product")
public class ProductController {

    @Autowired
    private IProductService productService;

    @GetMapping("/{id}")
    public String product(@PathVariable Integer id, Model model) {
        Product p = productService.getById(id);
        model.addAttribute("product", p);
        return "HomeAppliance";
    }
}
